package demo3;

public class My_Thread02 {
    public static void main(String[] args) {
        //初始化自定义线程
        MyThread02 myThread02 = new MyThread02();
        //启动线程,创建PCB,参与CPU调度
//        myThread02.start();

        myThread02.run(); // 只是JAVA对象的一个方法而已

        //主线程中的任务
        while (true) {
            try {
                //休眠1000毫秒
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("hello main thread...");
        }
    }
}

class MyThread02 extends Thread {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("hello my thread...");
        }
    }
}